import './utils/proto.js'
import './utils/utils.js'
import './utils/http.js'

// app.js
App({
  onLaunch() {
    // 小程序启动时，就获取本地的token，设置到app实例身上，供其他页面方便的访问
    this.token = this.getToken()
    this.refreshToken = this.getRefreshToken()
  },

  setToken(token) {
    wx.setStorageSync('token', token)
    this.token = token
  },

  getToken() {
    return wx.getStorageSync('token')
  },

  removeToken() {
    wx.removeStorageSync('token')
    delete this.token
  },

  setRefreshToken(refreshToken) {
    wx.setStorageSync('refreshToken', refreshToken)
    this.refreshToken = refreshToken
  },

  getRefreshToken() {
    return wx.getStorageSync('refreshToken')
  },

  removeRefreshToken() {
    wx.removeStorageSync('refreshToken')
    delete this.refreshToken
  },
})
